<?php
//员工接口
interface employee{
    public function working();
}

class teacher implements employee{
    public function working()
    {
        echo 'teaching...';
        // TODO: Implement working() method.
    }
}


class coder implements employee{
    public function working()
    {
        // TODO: Implement working() method.
        echo 'coding....';
    }
}


class workA{
    public function work(){
        $teacher = new teacher();
        $teacher->working();
    }
}

//工厂模式就是传递进去不同的参数  或者对象  可以实现不一样的结果

class workB{
    private $e;
    public function set(employee $e){
        $this->e = $e;
    }
    public function work(){
        $this->e->working();
    }
}


$workA = new workA();
$workA->work();
echo "\r\n";
$workB = new workB();
$workB->set(new coder());
$workB->work();




